package kong_gui_items;

import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class HudLife extends BaseGraphics {

	
	private static final long serialVersionUID = 8689026990864994276L;
	Integer lifeRemining = 6;
	String [] life;
	public HudLife() {
		

		super(5, 5, ".\\Resources\\Picts\\6.png", false);
		life = new String[]{".\\Resources\\Picts\\0.png",
									  ".\\Resources\\Picts\\1.png",
									  ".\\Resources\\Picts\\2.png",
									  ".\\Resources\\Picts\\3.png",
									  ".\\Resources\\Picts\\4.png",
									  ".\\Resources\\Picts\\5.png",
									  ".\\Resources\\Picts\\6.png"};
		
		
		File fileImg = new File(imageName);
		
		
		try {
			image = ImageIO.read(fileImg);
		} catch (IOException e) {
			image = null;
			System.err.println("Fichier invalide");
		}		
	}

	public Integer useLife(){
		
		
		try {
			
			image = ImageIO.read(new File(life[lifeRemining-1]));
			
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		lifeRemining--;
		return lifeRemining;
		
	}
	
	public Integer setLifeRemaining (Integer nbLives){
		
		try {
			
			image = ImageIO.read(new File(life[nbLives]));
			
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		lifeRemining = nbLives;
		return lifeRemining;
		
	}
	
	
}
